package com.rk.admin.service.impl;

import com.rk.admin.domain.Images;
import com.rk.admin.mapper.HomeImgMapper;
import com.rk.admin.service.HomeImgService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class HomeImgServiceImpl implements HomeImgService {

    @Autowired
    private HomeImgMapper homeImgMapper;

    /**
     * 查询首页轮播图
     * @return
     */
    public List<Images> findHomeImg(){
        return homeImgMapper.findHomeImg();
    }

    /**
     * 添加轮播图
     * @param images
     * @return
     */
    public Boolean addHomeImg(Images images){
        Date create=new Date();
        images.setCreattime(create);
        return homeImgMapper.insert(images)>0;//存入成功
    }


    /**
     * 通过id删除
     *
     * @param id
     * @return
     */
    @Override
    public Boolean deletebyid(int id) {
        return homeImgMapper.deleteById(id)>0;
    }
}
